package com.yueguang.springai.inode.impl;

import com.yueguang.springai.context.OrderContext;
import com.yueguang.springai.inode.INodeComponent;
import com.yueguang.springai.model.param.OrderParam;
import com.yueguang.springai.rule.RuleA;
import com.yueguang.springai.rule.RuleB;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Slf4j
@Component
@RuleA
@Order(1)
public class ANodeComponent implements INodeComponent {
    @Resource
    private CNodeComponent cNodeComponent;
    @Override
    public void handleData(OrderContext orderContext, OrderParam orderParam) {
        log.info("RuleA流程执行处理业务节点A-TM格式化报文");
        final List<String> executeRuleList = Optional.ofNullable(orderContext.getExecuteRuleList()).orElse(new ArrayList<>());
        executeRuleList.add("ANodeComponent");
        orderContext.setExecuteRuleList(executeRuleList);
        // 不同类型订单，订单号不同，可在节点中个处理
        orderContext.setOrderId("TOC11111");
        log.info("RuleA流程执行处理业务节点A-TM格式化报文-结束-调用流程C");
        cNodeComponent.handleData(orderContext, orderParam);
    }
}
